package com.red.servlet.order;

import com.red.service.impl.OrderServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "OrderPayServlet", value = "/payOrder")

public class OrderPayServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/plain;charset=utf-8");

        int order_id = Integer.parseInt(req.getParameter("order_id"));

        new OrderServiceImpl().pay(order_id);

        resp.setStatus(HttpServletResponse.SC_OK);
    }
}
